package com.aoxin.service.impl.course.systemCourse;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.aoxin.mapper.course.systemCourse.ThemeCourseDao;
import com.aoxin.model.dto.ThemeCourseDto;
import com.aoxin.service.inter.course.systemCourse.ThemeCourseService;
import com.aoxin.util.ErrorUtil;

@Service("themeCourseService")
public class ThemeCourseServiceImpl implements ThemeCourseService {
	@Autowired
	ThemeCourseDao themeCourseDao;
	
	@Override
	@Transactional
	public void insertThemeCourse(Integer[] schoolCourseIds) {
		 Assert.notEmpty(schoolCourseIds, ErrorUtil.CHECK_ADD_TO_PAGE);
		for (Integer  schoolCourseId : schoolCourseIds) {
			Integer check=this.themeCourseDao.checkSchoolCourseId(schoolCourseId);
			if(check==0){
				this.themeCourseDao.insertSelective(schoolCourseId);
			}
		}
	}

	@Override
	@Transactional
	public void deleteThemeCourse(List<Integer> themeCourseId) {
		Assert.notEmpty(themeCourseId, String.format(ErrorUtil.PARAMETER_NULL, "schoolCourseIds"));
		this.themeCourseDao.deleteThemeCourse(themeCourseId);
	}

	@Override
	public List<ThemeCourseDto> getThemeCourse(ThemeCourseDto themeCourseDto) {
		return this.themeCourseDao.getThemeCourse(themeCourseDto);
	}
	
	
	
	

}
